
<template>
    <view>
        <!-- #ifdef MP-WEIXIN -->
        <view v-if="isCanUse">
            <view>
                <view class='header'>
                   <!-- <image src='../../static/img/wx_login.png'></image> -->
                </view>
                <view class='content'>
                    <view>申请获取以下权限</view>
                    <text>获得你的公开信息(昵称，头像、地区等)</text>
                </view>

                <button class="bottom" type="primary" @tap="wxGetUserInfo">授权登录</button>
            </view>
        </view>
        <!-- #endif -->
		
    </view>
</template>


<script>
    export default {
        data() {
            return {
                SessionKey: '',
                OpenId: '',
                nickName: null,
                avatarUrl: null,
                isCanUse: uni.getStorageSync('isCanUse')||true//默认为true
            };
        },
        methods: {
            //授权获取用户信息===》按钮触发
            wxGetUserInfo(res) {
                wx.getUserProfile({
                  desc:'正在获取',//不写不弹提示框
                  success:function(res){
					console.log(res.userInfo)
					uni.setStorageSync('userInfo',res.userInfo);
                    wx.showToast({
                      title:'授权成功',
                      mask:true
                    })
                    setTimeout(res=>{
                      //跳转到上级界面
                      wx.navigateBack();
                    }, 1500)
                  },
                  fail:function(err){
                    console.log("获取失败: ",err)
                    wx.navigateBack();
                  }
                })
            },

　　　　　　
         
        },
       
    }
</script>

<style>
    .header {
        margin: 90rpx 0 90rpx 50rpx;
        border-bottom: 1px solid #ccc;
        text-align: center;
        width: 650rpx;
        height: 300rpx;
        line-height: 450rpx;
    }

    .header image {
        width: 200rpx;
        height: 200rpx;
    }

    .content {
        margin-left: 50rpx;
        margin-bottom: 90rpx;
    }

    .content text {
        display: block;
        color: #9d9d9d;
        margin-top: 40rpx;
    }

    .bottom {
        border-radius: 80rpx;
        margin: 70rpx 50rpx;
        font-size: 35rpx;
    }
</style>
